<!DOCTYPE html>
<html>
<head>
    <title>我的申请</title>
</head>
<body class="layui-layout-body">
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="body_right">
            <h4 class="nav_title">授权印章</h4>
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                     <li lay-id="APPLY_LIST">申请记录</li>
			         <li class="layui-this" >授权记录</li>
                </ul>
                <div class="layui-tab-content" style="height: 100px;">
                    <div class="layui-tab-item layui-show">
                        <form action="/record/approveList.htm" class="layui-form no_bordertop" >
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">印章名称</label>
                                     <div class="layui-input-inline" style="width:150px">
                                        <input type="text" class="layui-input" name="sealName" value="${query.sealName}" id="sealName" placeholder="">
                                    </div>
                                </div>
                                <div class="layui-inline">
					                        <label class="layui-form-label">申请类型</label>
					                        <div class="layui-input-inline" style="width:100px">
					                            <select name="applyType" lay-filter="aihao">
					                                <option value="">全部</option>
					                                <option value="USED_APPLY" <#if query.applyType=='USED_APPLY'>selected=""</#if>>申请使用</option>
					                                <option value="TAKE_APPLY" <#if query.applyType=='TAKE_APPLY'>selected=""</#if>>申请外带</option>
					                            </select>
					                        </div>
					                    </div>
                                <div class="layui-inline width80">
                                    <div class="layui-input-inline ">
                                        <button class="layui-btn" lay-submit="" lay-filter="demo1" >搜索</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                        <table class="layui-table mytable" lay-even="" lay-skin="nob">
                            <thead>
	                            <tr>
	                                <th>印章名称</th>
	                                <th>类型</th>
	                                <th>可用次数</th>
	                                <th>剩余次数</th>
	                                <th>申请事由</th>
	                                <th>使用凭证</th>
	                                <th>核查状态</th>
	                                <th>操作</th>
	                            </tr>
                            </thead>
                            <tbody>
                            	   <#list pm.datas as item>
	                            <tr>
	                                <td>${item.seal.sealName}</td>
	                                <td>
	                                		<@linkage type="APPLY_TYPE" key=item.applyType>
								        		<span class="${linkage.style}">${linkage.name}</span>
								        	</@linkage>  
	                                </td>
	                                <td>${item.totalTimes} 次</td>
	                                <td>${item.useTimes} 次</td>
	                                <td>${item.cause}</td>
	                                <td>
	                                	<#if item.usedStatus =='WAIT_UPLOAD_CERT'>
	                                	<button class="layui-btn layui-btn-normal layui-btn-xs uploads" lay-data="{devicesId: ${item.devicesId},devicesActId:${item.devicesActId}}">上传</button>
	                                	<#elseif item.usedStatus =='SUCCESS'>
	                                	已上传
	                                	<#else>
	                                	待使用
	                                	</#if>
	                                	
	                                	
	                                </td>
	                                <td>
	                                	<#if item.censorStatus =='WAIT'>
	                                		待核查
	                                	</#if>
	                                	
	                                	<#if item.censorStatus =='CHECKED'>
	                                		已核查
	                                	</#if>
	                                </td>
	                                <td class="aline_a">
	                                	<a href="javascript:openwinx('查看','/record/approveInfo.htm?devicesActId=${item.devicesActId}',800,500);">查看</a>
	                                </td>
	                            </tr>
	                            </#list>
                            </tbody>
                        </table>
                        <@p.page pm=pm></@p.page>
                    </div>
                    
                </div>
            </div>
        </div>
     </div>
	<script>
		layui.use(['element','laydate','upload'], function(){
		  var $ = layui.jquery,element = layui.element,laydate = layui.laydate,upload=layui.upload; 
		  element.on('tab(docDemoTabBrief)', function(elem){
		  		var id = $(this).attr('lay-id');
		  		if(id == 'APPLY_LIST'){
		  		 	location.href='/record/applyList.htm';
		  		}
		  		
		  		//if(id == 'USED'){
		  		//	 location.href='/apply/used/list.htm';
		  		//}
		  		
		  		if(id == 'TAKE'){
		  			 location.href='/apply/take/list.htm';
		  		}
		  });
		  
		  
	     upload.render({
		    elem: '.uploads'
		    ,url: '/upload/fileupload.htm?module=cert'
		    
		    ,done: function(res, index, upload){
		      var devicesId = this.devicesId;
		      var devicesActId = this.devicesActId;
		   
		      if(res.code == 1){
		      		
		      		var field = {
		      			devicesId:devicesId,
		      			devicesActId:devicesActId
		      		}
		      		field['upfiles[0].upfileId'] = res.data.upfileId;
		          	field['upfiles[0].fileUrl'] = res.data.filepath;
		      		
		      		$.ajax({
		      			type:"POST", 
		      			url:"/devices/upcert.htm",
		      			data:field,
		      			success:function(result) {
				      
				      		if(result.code=='1'){
				      			layer.msg("上传成功");
				      			location.reload();
				      		}else{
				      		 	layer.msg(result.msg);
				      		}
				      
				    	 	} 
				    }); 
		      	
		      
		      }
		      
		    }
		  })
		  
		  
		  
		  
		  
		  
		  
		  
		  
	  
		});
	</script>
</body>
</html>